package com.zjhn.ds.controller.app.pad;

import com.alibaba.fastjson.JSON;
import com.zjhn.ds.common.BizResult;
import com.zjhn.ds.domain.dto.pad.GroupInfoDto;
import com.zjhn.ds.domain.dto.pad.GroupRelDto;
import com.zjhn.ds.param.AddGroupParam;
import com.zjhn.ds.param.GroupBindParam;
import com.zjhn.ds.param.GroupUnBindParam;
import com.zjhn.ds.service.PersonnelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @BelongsProject: ds_jlw
 * @BelongsPackage: com.zjhn.ds.controller.app.pad
 * @Author: sxt
 * @CreateTime: 2023-09-22  10:02
 * @Description:
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/jlw/personnel")
@Api(tags = "pad端人员列表接口")
public class PersonnelController {

    @Resource
    private PersonnelService personnelService;

    @ApiOperation("获取分组信息")
    @GetMapping("/getGroupList")
    public BizResult<List<GroupInfoDto>> getGroupList(@RequestParam("workshop_id") String workshopId) {
        log.info("====[INFO]========PersonnelController====getGroupList workshopId:{}", workshopId);
        return personnelService.getGroupList(workshopId);
    }

    @ApiOperation("获取分组关联信息")
    @GetMapping("/getGroupRel")
    public BizResult<GroupRelDto> getGroupRel(@RequestParam("group_id") String groupId) {
        log.info("====[INFO]========PersonnelController====getGroupRel groupId:{}", groupId);
        return personnelService.getGroupRel(groupId);
    }

    @ApiOperation("新增组别")
    @PostMapping("/addUpdateGroup")
    public BizResult<?> addUpdateGroup(@RequestBody @Valid AddGroupParam param) {
        log.info("====[INFO]========PersonnelController====addUpdateGroup param:{}", JSON.toJSONString(param));
        return personnelService.addUpdateGroup(param);
    }

    @ApiOperation("删除组别")
    @GetMapping("/removeGroup")
    public BizResult<?> removeGroup(@RequestParam("group_id") String groupId) {
        log.info("====[INFO]========PersonnelController====removeGroup groupId:{}", groupId);
        return personnelService.removeGroup(groupId);
    }

    @ApiOperation("组别批量绑定挡车工或工位")
    @PostMapping("/groupBind")
    public BizResult<?> groupBind(@RequestBody @Valid GroupBindParam param) {
        log.info("====[INFO]========PersonnelController====groupBind param:{}", JSON.toJSONString(param));
        return personnelService.groupBind(param);
    }

    @ApiOperation("组别解绑挡车工或工位")
    @PostMapping("/groupUnBind")
    public BizResult<?> groupUnBind(@RequestBody @Valid GroupUnBindParam param) {
        log.info("====[INFO]========PersonnelController====groupUnBind param:{}", JSON.toJSONString(param));
        return personnelService.groupUnBind(param);
    }

}
